<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class="app-container">
    <el-form id="mvcfm">
      <el-row>
        <el-col :span="10" :xs="24">
          <div class="form-unit">
            <span class="mvc-title-left"> 我的日历 </span>
          </div>
          <div>
          </div>
          <el-select @change="list_s_year" v-model="s_search.CMIDSEL1">
            <el-option label="－－无－－" value='' />
            <el-option v-for="dict in s_year" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
          </el-select>
          <el-select @change="list_s_month" v-model="s_search.CMIDSEL2">
            <el-option label="－－无－－" value='' />
            <el-option v-for="dict in s_month" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
          </el-select>
          <table id='calendarTable' cellspacing="0" border="0" class='el-table el-table--fit el-table--enable-row-hover el-table--enable-row-transition'>
            <thead class="el-table__header-wrapper">
              <tr>
                <th>周7</th>
                <th>周1</th>
                <th>周2</th>
                <th>周3</th>
                <th>周4</th>
                <th>周5</th>
                <th>周6</th>
              </tr>
            </thead>
            <tbody class="el-table__body">
              <tr v-for="(trrow, trindex) in s_calendar">
                <td v-for="(row, status) in trrow" :style="{background:row.background}">
                  <p>
                    <el-link @click="gotoPage('A145907DE41C4B979A76F2F4C41FC423?&thisdate='+row.date+''+vueparams+'')" type='primary'>{{row.date_title}}</el-link>
                    <el-link @click="gotoPage('A145907DE41C4B979A76F2F4C41FC423?'+vueparams+'')" type='primary'>{{row['']}}</el-link>
                  </p>
                  <p>
                    {{row.lunar}}
                  </p>
                  <p>
                    {{empty}}
                  </p>
                  <p>
                    <font color="green" v-if="row['htcomcount']>0">{{row['htcomcount']}} </font>
                    <font color="blue" v-if="row['htnocount']>0">{{row['htnocount']}} </font>
                    <font color="red" v-if="row['htallcount']>0">{{row['htallcount']}} </font>
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
          <div>
            <el-menu :default-active='activeIndex' mode='vertical' class='menu-unit'>
              <el-menu-item index="3">
                <span style="color:green;">绿色</span>代表正在执行任务数
              </el-menu-item>
              <el-menu-item index="4">
                <span style="color:blue;">蓝色</span>代表已完成任务数
              </el-menu-item>
              <el-menu-item index="5">
                <span style="color:red;">红色</span>代表我布置任务数
              </el-menu-item>
            </el-menu>
          </div>
        </el-col>
        <el-col :span="14" :xs="24">
          <div class="form-unit">
            <span class="mvc-title-left"> 请假申请列表 </span>
          </div>
          <div>
          </div>
          <el-select placeholder='请假类型' v-model="empty">
            <el-option label="所有" value="所有" />
          </el-select>
          <div class="el-select">
            <el-input v-model="empty" placeholder='标题' />
          </div>
          <el-date-picker v-model="empty" type="date" placeholder='请假时间' value-format="yyyy-MM-dd" />
          <el-date-picker v-model="empty" type="date" placeholder='结束时间' value-format="yyyy-MM-dd" />
          <div class="el-select">
            <el-input v-model="empty" placeholder='流程实例ID' />
          </div>
          <el-button @click="gotoPage(''+vueparams+'')" type='primary' size="mini"><i class='fa fa-search'></i>搜索</el-button>
          <el-button @click="gotoPage(''+vueparams+'')" type='warning' size="mini"><i class='fa fa-refresh'></i>重置</el-button>
          <el-button @click="gotoPage(''+vueparams+'')" type='success' size="mini"><i class='fa fa-plus'></i>添加</el-button>
          <el-table :data="pageList" v-loading="loading" @selection-change="handleSelectionChange">
            <el-table-column label="操作" align="center" width='100' type=''>
              <template slot-scope="scope">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                      <el-link @click="popedit('&id='+scope.row.id+'')">表单数据</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <el-link @click="pophistoryList('&CMIDinstance_id='+scope.row.instance_id+'')">审批历史</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <el-link @click="popprocessImg('&pProcessInstanceId='+scope.row.instance_id+'')">进度查看</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <el-link @click="submitApply('')">提交申请</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <el-link @click="popedit('')">编辑</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <el-link @click="remove('')">删除</el-link>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </template>
            </el-table-column>
            <el-table-column label="#" align="center" type='selection'>
            </el-table-column>
            <el-table-column label="请假类型" prop="type">
            </el-table-column>
            <el-table-column label="标题" prop="title">
            </el-table-column>
            <el-table-column label="原因" prop="reason">
            </el-table-column>
            <el-table-column label="开始时间" prop="start_time">
            </el-table-column>
            <el-table-column label="结束时间" prop="end_time">
            </el-table-column>
            <el-table-column label="请假时长" prop="total_time">
            </el-table-column>
            <el-table-column label="流程实例ID" prop="instance_id">
            </el-table-column>
            <el-table-column label="创建人ID" prop="create_by">
            </el-table-column>
            <el-table-column label="创建人" prop="create_user_name">
            </el-table-column>
            <el-table-column label="申请人ID" prop="apply_user">
            </el-table-column>
            <el-table-column label="申请人" prop="apply_user_name">
              <template slot-scope="scope">
                {{scope.row.apply_user_name}}
              </template>
            </el-table-column>
            <el-table-column label="申请时间" prop="apply_time">
            </el-table-column>
            <el-table-column label="当前任务ID" prop="task_id">
            </el-table-column>
            <el-table-column label="当前任务名称" prop="task_name">
            </el-table-column>
          </el-table>
        </el-col>
      </el-row>
    </el-form>
    <el-dialog :visible.sync="editVisible" append-to-body>
      <edit v-if="editVisible" ref="edit" :popparams="popparams"> </edit>
    </el-dialog>
    <el-dialog :visible.sync="historyListVisible" append-to-body>
      <historyList v-if="historyListVisible" ref="historyList" :popparams="popparams"> </historyList>
    </el-dialog>
    <el-dialog :visible.sync="processImgVisible" append-to-body>
      <processImg v-if="processImgVisible" ref="processImg" :popparams="popparams"> </processImg>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import edit from "@/views/oa/process/leave/edit";
  import historyList from "@/views/oa/process/general/historyList";
  import processImg from "@/views/oa/process/general/processImg";
  export default {
    name: 'leave',
    components: {
      edit,
      historyList,
      processImg,
    },
    props: ['popparams'],
    data() {
      return {
        editVisible: false,
        editValue: null,
        editDesc: null,
        historyListVisible: false,
        historyListValue: null,
        historyListDesc: null,
        processImgVisible: false,
        processImgValue: null,
        processImgDesc: null,
        vueparams: this.getVUEParams(""),
        s_search: {},
        s_calendar: [],
        s_year: [],
        s_month: [],
        loading: true,
        pageList: [],
        pageSize: 10,
        total: null,
        elcheck: [],
        multiple: true,
        rules: {}
      }
    },
    created() {
      this.getData();
      this.getPage(1);
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/oa/process/LeaveAction/leaveLoad?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      export (_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/oa/process/LeaveAction/export?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      remove(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/oa/process/LeaveAction/remove?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      submitApply(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/oa/process/LeaveAction/submitApply?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      getPage(page) {
        this.loading = true;
        request({
          method: 'get',
          url: '/xcapi/VUEAction/oa/process/LeaveAction/list?' + this.vueparams,
          params: {
            pageNo: page
          }
        }).then(data => {
          this.loading = false;
          this.pageList = data.rows;
          this.total = data.total;
        })
      },
      list_s_year(value) {
        if (this.$route.fullPath.indexOf("?") == -1) {
          this.$router.replace("/redirect" + this.$route.fullPath + "?CMIDSEL1=" + value);
        } else if (this.$route.fullPath.indexOf("CMIDSEL1=") == -1) {
          this.$router.replace("/redirect" + this.$route.fullPath + "&CMIDSEL1=" + value);
        } else {
          this.gotoPage("/redirect/oa/process/leave/leave?" + this.vueparams, {
            CMIDSEL1: value
          });
        }
      },
      list_s_month(value) {
        if (this.$route.fullPath.indexOf("?") == -1) {
          this.$router.replace("/redirect" + this.$route.fullPath + "?CMIDSEL2=" + value);
        } else if (this.$route.fullPath.indexOf("CMIDSEL2=") == -1) {
          this.$router.replace("/redirect" + this.$route.fullPath + "&CMIDSEL2=" + value);
        } else {
          this.gotoPage("/redirect/oa/process/leave/leave?" + this.vueparams, {
            CMIDSEL2: value
          });
        }
      },
      popedit(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.editVisible = !this.editVisible;
      },
      pophistoryList(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.historyListVisible = !this.historyListVisible;
      },
      popprocessImg(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.processImgVisible = !this.processImgVisible;
      },
      handleSelectionChange(selection) {
        this.elcheck = selection.map(item => item["id"]);
        this.single = selection.length != 1;
        this.multiple = !selection.length;
      },
    },
  }
</script>
